package main

import "sort"

func findDuplicate(nums []int) int {
	sort.Slice(nums, func(i, j int) bool {
		if nums[i] < nums[j] {
			return true
		}

		return false
	})

	i := 0
	for ; i < len(nums)-1; i++ {
		if nums[i] == nums[i+1] {
			break
		}
	}

	return nums[i]
}
